package com.collection;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;

public class SetListSafe {

    public static void main(String[] args) {


//        Collections.synchronizedSet(new HashSet<>());


        Map<String,String> map = Collections.synchronizedMap(new HashMap<>());

        for (int i = 0; i < 20; i++) {

            new Thread(()->{

                for (int j = 0; j < 10; j++) {

                    map.put(UUID.randomUUID().toString().substring(0,10),UUID.randomUUID().toString().substring(0,10));
                }

                System.out.println(map);
            }).start();
        }
    }
}
